package com.dream.keigezhushou.Activity.acty.personal;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.activity.BaseActivity;
import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NativeRecordActivity extends BaseActivity {

    @BindView(R.id.iv_return)
    ImageView ivReturn;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.lv_native_record)
    ListView lvNativeRecord;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_native_record);
        ButterKnife.bind(this);

        initView();
        initData();
    }

    //初始化界面
    protected void initView(){

        tvTitle.setText("本地录音");

    }

    //初始化数据
    protected void initData(){

        ivReturn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //返回
                finish();
            }
        });

        //ListView创建适配器
        lvNativeRecord.setAdapter(new NativeAdapter(this));
    }

    public class NativeAdapter extends BaseAdapter {

        private Context mContext;
        int c = 10;
        public NativeAdapter(Context context){

            this.mContext = context;
        }

        @Override
        public int getCount() {
            return c;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public Object getItem(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            ViewHolder mHolder = null;
            if (view == null){

                view = LayoutInflater.from(mContext).inflate(R.layout.layout_native_item,null);

                mHolder = new ViewHolder();
                mHolder.rlKind1 = (RelativeLayout) view.findViewById(R.id.rl_kind1);
                mHolder.rlKind2 = (RelativeLayout) view.findViewById(R.id.rl_kind2);
                view.setTag(mHolder);

            }else {

                mHolder = (ViewHolder)view.getTag();
            }

            if (i % 2 == 0){

                mHolder.rlKind1.setVisibility(View.GONE);
                mHolder.rlKind2.setVisibility(View.VISIBLE);
            }else {

                mHolder.rlKind1.setVisibility(View.VISIBLE);
                mHolder.rlKind2.setVisibility(View.GONE);
            }
            return view;
        }

        class ViewHolder{

            RelativeLayout rlKind1,rlKind2;
            TextView tvSongName;

        }
    }
}
